<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of articles
 *
 * @author IT
 */
class articles extends db {

    function xemar($page) {
        
        

        $query = "SELECT * FROM articles LIMIT " . (($page - 1) * 2) . ',2';
        $data = $this->xemdl($query);
        return $data;
    }

    function viewar() {
        $view = $_GET['view'];
        $query = "SELECT * FROM articles WHERE id = " . $view;
        $data = $this->xemdl($query);
        return $data;
    }

    function viewar_cate() {
        $view = $_GET['view1'];
        $query = "SELECT * FROM articles WHERE id_category = " . $view;
        $data = $this->xemdl($query);
        return $data;
    }

    function arall() {
        $query = " SELECT * FROM articles ";
        $data = $this->xemdl($query);
        return $data;
    }
    function arket()
    {
        $query = " SELECT ar.id ,ar.title ,ar.overview ,ar.body ,ar.id_category ,ca.name FROM articles as ar INNER JOIN categories as ca ON ar.id_category = ca.id";
        $data = $this->xemdl($query);
        return $data;
        
    }
        function viewupda() {
        $view = $_GET['id'];
        $query = "SELECT * FROM articles  WHERE id = " . $view;
        $data = $this->xemdl($query);
        return $data;
    }
    
    function postsearch($key)
    {
        $query = "SELECT * FROM articles WHERE title LIKE '%$key%' OR body LIKE '%$key%' ";
        $data = $this->xemdl($query);
        return $data;
    }
}
